#!/bin/sh
#
# Set LOCALDIR based on $LANG
#
SWIN2HOME=$1

# Currently Supported Keyboards
#
# Prom indicators (only used on INDY/Indigo2/PowerIndigo2 Systems)
#
# fr = FRA, FR
# gr = DE, DEU 
# uk = GBR, GB
# us = USA, US 
#

case `nvram keybd` in
	FRA|FR)
		LOCALDIR=$SWIN2HOME/local/SGIfr
	;;
	DEU|DE)
                LOCALDIR=$SWIN2HOME/local/SGIgr
	;;
	GRB|GB)
                LOCALDIR=$SWIN2HOME/local/SGIuk
	;;
	*)
                LOCALDIR=$SWIN2HOME/local/SGIus
	;;	
esac

# This is an evil hack to deal with a preexisting 1.2 or 1.1 .hdf file in
# $SWIN2HOME. We need to keep it but inst will dump it. So... we noupdate install
# a junk file and a copy of it. If they aren't different, then we can delete
# them, if they are then we need to rename one and dump the other.
#
#if  `cmp -s $SWIN2HOME/MS-WIN-311.hdf $SWIN2HOME/.MS-WIN-311.hdf`
#then
        # They are both junk
#        rm $SWIN2HOME/MS-WIN-311.hdf
#        rm $SWIN2HOME/.MS-WIN-311.hdf
#else
        # There was a real one left behind
#        mv $SWIN2HOME/MS-WIN-311.hdf $SWIN2HOME/SAVED-MS-WIN-311.hdf
#        rm $SWIN2HOME/.MS-WIN-311.hdf
#fi
#
# If this is an IP22 then install the US INDY Keyboard
#
#if [ "`uname -m`" = "IP22" -o "`uname -m`" = "IP26" ]
#then
        # We're on an Indy
#	cat $SWIN2HOME/sys.swin2config | sed -f $LOCALDIR/upd_i_keymap > $SWIN2HOME/new.swin2config
#	mv $SWIN2HOME/new.swin2config $SWIN2HOME/sys.swin2config
#fi
#
# Assume US installation (for right now)
#
( cd $LOCALDIR/local ; find . -print | cpio -pud $SWIN2HOME/local )

#
# Update the File Type Rules and icons
#
cd $rbase/usr/lib/filetype
make

#
# Put the icon in the catalog
#
if [ -x $rbase/usr/sbin/iconbookedit ]
then
    chroot $rbase /usr/sbin/iconbookedit -add "Category:File Name:/usr/lib/SoftWindows2/bin/SoftWindows2" -syspage Applications
    chroot $rbase /usr/sbin/iconbookedit -add "Category:File Name:/usr/lib/SoftWindows2/bin/SoftWindows2" -syspage WhatsNew
fi

#
# Setup the fonts
#
$rbase/usr/bin/X11/xset +fp $SWIN2HOME/fonts/SGI
$rbase/usr/bin/X11/xset fp rehash

#
# Make sure there's a /CDROM and /floppy directory
#
mkdir /floppy 1>/dev/null 2>&1
mkdir /CDROM 1>/dev/null 2>&1

#
# remove any 1.2 version ids older then us
#
#rm $SWIN2HOME/.12000001
#rm $SWIN2HOME/.12000002
#rm $SWIN2HOME/.12000003

#
# setup the system 4Dwmrc file
#
mv $rbase/usr/lib/X11/system.4Dwmrc $rbase/usr/lib/X11/system.4Dwmrc.O
mv $rbase/usr/lib/X11/system.4Dwmrc.swin $rbase/usr/lib/X11/system.4Dwmrc


#
# Move new license (if any) to appropriate location
#
if [ -r /var/tmp/20license.dat ]; then
  mv /var/tmp/20license.dat $rbase/usr/lib/SoftWindows2/FLEXlm/license.dat
fi

if [ -r /var/tmp/125license.dat ]; then
  mv /var/tmp/125license.dat $rbase/usr/lib/SoftWindows2/FLEXlm/125license.dat
fi


#
# Clean up
#
rm $rbase/var/tmp/swin* 1>/dev/null 2>&1
rm $rbase/var/tmp/junk 1>/dev/null 2>&1
exit 0




















